import db from '@dfeidao/atom-nodejs/db';
import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '../atom/config';
interface Message {
	productid: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:app-my-schedule/s003,action_id:' + action_id);

	log('Service end path:app-my-schedule/s003,action_id:' + action_id);
	const { exec, prepare } = db.query(action_id, session_id, systemid);
	prepare('grade', ['grade_no', 'grade'], { productid: message.productid }, 199, 1, [], []);
	prepare('class', ['class_id', 'class_name'], { productid: message.productid }, 199, 1, [], []);
	const [data] = await exec();
	return {
		data: { data }
	};
}
